package com.netty.rpc.listener;

import com.netty.rpc.resp.Response;
import io.netty.channel.ChannelHandlerContext;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.FutureListener;

public class ServerFutureListener implements FutureListener<Response> {

    public ChannelHandlerContext channelHandlerContext;

    public ServerFutureListener(ChannelHandlerContext channelHandlerContext){
        this.channelHandlerContext = channelHandlerContext;
    }

    @Override
    public void operationComplete(Future<Response> future) throws Exception {
        Response message = future.get();
        channelHandlerContext.channel().writeAndFlush(message);
    }
}
